<?php
/**
 * Created by PhpStorm.
 * User: yellow
 * Date: 2019/8/5
 * Time: 16:52
 */

namespace app\admin\logic;


use app\admin\logic\code\ErrorCode;
use app\common\model\UserInfo;

class TravelAgencyLogic extends BaseLogic
{

    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 旅行社列表
     */
    public function travelList($tempWhere, $nowPage){
        $where = [];
        if ($tempWhere['company']){
            $where[] = ['company', 'like', "%".$tempWhere['company']."%"];
        }
        if ($tempWhere['business_number']){
            $where[] = ['business_number', 'like', "%".$tempWhere['business_number']."%"];
        }
        $count = UserInfo::where($where)->count();
        if ($count <= 0){
            return ajaxArr(ErrorCode::$LISTNULL, '旅行社列表为空');
        }

        $list = UserInfo::where($where)->page($nowPage, self::$pageNum)->select();
        return ajaxArr(ErrorCode::$SUCCESS, 'success', $list);
    }

    /**
     * 旅行信息
     * @param $id
     * @return mixed
     */
    public function travelInfo($id){
        if (!$id){
            return ajaxArr(ErrorCode::$INFONULL, '该信息不存在');
        }

        $info = UserInfo::get($id);
        return ajaxArr(ErrorCode::$INFONULL, '信息不存在', $info);
    }

}